package cn.itcast.manus.controller;

import cn.itcast.manus.dto.DialogMessageDTO;
import cn.itcast.manus.service.WebSocketService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.stereotype.Controller;

@Slf4j
@Controller
@RequiredArgsConstructor
public class WebSocketController {

    private final WebSocketService webSocketService;

    @MessageMapping("/enhanced-dialog")
    public void enhancedDialog(@Payload DialogMessageDTO message, SimpMessageHeaderAccessor headerAccessor) {
        log.info("enhancedDialog: {}, sessionId:{}", message, headerAccessor.getSessionId());
        this.webSocketService.enhancedDialog(message, headerAccessor);
    }

}
